﻿@using ActivtyUI.Controllers;
@using EmoneyWeiXinCommon;
@using EmoneyWeiXinEntity
@{
    Layout = null;
    int gift = ViewBag.Gift;
    weixinUserEntity wxInfo = ViewBag.wxInfo as weixinUserEntity; 
}

<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>奖品结果</title>
    <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport">
    <meta name="format-detection" content="telephone=no" />
    <meta name="format-detection" content="email=no" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black" />
    <script type="text/javascript">
        (function (doc, win) {
            var docEl = doc.documentElement,
                resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',
                recalc = function () {
                    var clientWidth = docEl.clientWidth < 768 ? docEl.clientWidth : 768;
                    if (!clientWidth) return; docEl.style.fontSize = 16 * (clientWidth / 320) + 'px';
                }; recalc();
            if (!doc.addEventListener) return; win.addEventListener(resizeEvt, recalc, false);
        })(document, window);
    </script>

    <link href="@Url.Content("~/css/NineMonth/basic.css")?a=@(new Random().Next())" rel="stylesheet" />
    <script src="@Url.Content("~/js/jquery.js")"></script>
    <script src="@Url.Content("~/js/jweixin-1.0.0.js")"></script>
    <script src="@Url.Content("~/js/WeiXinCommon2.js")?a=@(new Random().Next())"></script>
    <script type="text/javascript">
        var isToIndex = false;
        (function ($) {
            var currOpenId = '@ViewBag.openid';

            $(function () {  //页面加载时
                initEvent();
            });
            function showLoading() {
                var margintop = (document.documentElement.clientHeight) / 2 - 20;
                var marginleft = (document.documentElement.clientWidth) / 2 - 20;
                $("#subLoadDiv").css({ "margin-top": margintop, "margin-left": marginleft });
                $("#loadDiv").show();
            }
            function hideLoading() {
                $("#loadDiv").hide();
            }
            function hideShare() {
                $("html").removeClass("tt");
                $(".share").hide();
                $(".share").removeClass("win");
            }

            function initEvent() {
                //a 点击事件开始
                $("#btnAtag").click(function () {
                    if ('@gift' == '@((int)GiftEnum.DanGong)' || '@gift' == '@((int)GiftEnum.LaTiao)' || '@gift' == '@((int)GiftEnum.TiaoTiaoTang)') {
                        $.ajax({
                            url: '@Url.Action("TiXian", "NineMonthActive")',
                            type: 'post',
                            data: { openid: currOpenId },
                            beforeSend: function () {
                                showLoading();
                            },
                            complete: function () {
                                hideLoading();
                            },
                            success: function (data) {
                                alert(data);
                                if (data.indexOf("提现成功")>=0) {
                                    $(".share").show(1).delay(5000).hide(1, 0, hideShare);
                                }
                            }

                        });
                    }
                    else {
                        if ('@gift' == '@((int)GiftEnum.DaLiBao)') {
                            window.location.href = "@Url.Action("AddressInfoPage", "NineMonthActive")?openid=" + currOpenId;
                        }
                        else if ('@gift' == '@((int)GiftEnum.None)') { //如果没有中奖
                            if (isToIndex) {
                                window.location.href = "@Url.Action("Index", "NineMonthActive")?openid=" + currOpenId;
                            } else
                                if ('@ViewBag.is2Chance' != '2') {
                                    $(".share").show(1).delay(5000).hide(1, 0, hideShare);
                                } else {
                                    alert('我们已经给过您机会，无奈您手气不妙！期望您的朋友能中大奖！');
                                }
                        }
                }

                });
                //a点击事件结束
            $(".share").click(function () {
                hideShare();
            });
        }
        })(jQuery);

    //当执行分享动作的时候执行
    function sharaEvent(type) {
        $.ajax({
            url: '@Url.Action("ShareAct", "NineMonthActive")',
            type: 'post',
            data: { openid: '@ViewBag.openid', sharaType: type },
            success: function (data) {
                if (data == "1") {//说明分享记录添加成功
                    if ('@gift' == '@((int)GiftEnum.None)' && '@ViewBag.is2Chance' != '2' && (!isToIndex)) {
                            isToIndex = true;
                            alert("分享成功，再次点击\n'求求你再给我一次机会'\n就可以跳转到游戏页再次进行游戏！");
                        }
                    }
                }
        });
        }
    </script>
</head>
<body onload="rize()" onresize="rize()">
    <div class="box_A">
        <p class="box_A_bg" style="background:url(@Url.Content("~/images/NineMonth/bg01.png"))  no-repeat center">
        </p>
        <div class="@(gift == (int)GiftEnum.None ? "content" : "content02")">
            <p class="@(gift == (int)GiftEnum.None ? "prize_01_top" : "prize_02")">
                <img src="@Url.Content("~/images/NineMonth/" + ViewBag.Img)" /><a href="#" id="btnAtag"></a>

            </p>
            @if (gift == (int)GiftEnum.None)
            {
                <p class="prize_01_bottom">
                    <img src="@Url.Content("~/images/NineMonth/prize01_bottom.png")">
                </p>
            }
        </div>
    </div>
    @*<input type="button" value="Monifenxiang" onclick="sharaEvent(1)" />*@
    <div style="width: 100%; height: 100%; display: none; position: absolute; top: 0px; left: 0px;" id="loadDiv">
        <div id="subLoadDiv">
            <img src="@Url.Content("~/images/load.gif")" />
        </div>

    </div>
    <div class="share">
        <h3>
            <img src="@Url.Content("~/images/NineMonth/share.png")" /></h3>
        @if (gift ==(int) GiftEnum.None)
        { <p>
             点击右上角“...”分享朋友圈,邀请你的朋友一起来玩吧！<br />
             分享之后，我们将再给你一次抽奖的机会<br />
             赶快动起来！<br />

         </p> }else{
        <p>
             哇噻，你好幸运，恭喜你领取了小盟发放的“零花钱”。<br />
             分享至“朋友圈”，邀请朋友一起玩吧！
         </p>
              }
    </div>
</body>


</html>

<script>
    function rize() {
        var height = document.documentElement.clientHeight;
        $("body").css({ "height": height });
        $(".box_A").css({ "height": height });
    }
</script>

@*  关于微信分享部分的代码*@
<script type="text/javascript">
    var AppId = "@wxInfo.AppId";
    var AppSercret = "@wxInfo.AppSecret";
    var shareUrl = "@System.Configuration.ConfigurationManager.AppSettings["jyhdwzUrl"]";
    var timestamp = "@ViewBag.timestamp";
    var imgUrl = "@Config.Host_Url3" + "images/NineMonth/" + "shareImg.png";
    var tTitle = "看哭了，童年的记忆，每张图都戳中泪点";
    var tContent = "好棒的文章，深度戳泪，回忆泛滥。还能玩转盘，赢得大礼。快来跟我一起回忆吧！";
    var nonceStr = "@ViewBag.nonceStr";
    var signature = "@ViewBag.signature";

    ///初始化分享到朋友圈的功能
    function initSharePara() {
        mysharetime(shareUrl, imgUrl, tTitle, tContent, AppId, timestamp, nonceStr, signature, sharaEvent);
    }
    initSharePara();
</script>
